﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace PollSystemService
{
    [ServiceContract]
    public interface IPollSystemService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        List<string> GetQuestions();

        [OperationContract]
        [WebInvoke()]
        List<string> GetAnswers(string questionID);

        [OperationContract]
        [WebInvoke()]
        List<Answer> Vote(Vote vote);        
    }

    [DataContract]
    public class Answer
    {
        [DataMember]
        public string Question { get; set; }

        [DataMember]
        public string AnswerText { get; set; }

        [DataMember]
        public int AnswerCount { get; set; }
    }

    [DataContract]
    public class Vote
    {
        [DataMember]
        public int QuestionID { get; set; }

        [DataMember]
        public string Answer { get; set; }
    }
}
